home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / ViewIt™ 2.24 Shareware / FaceWare / FaceWare.rsrc / TEXT_1317_BC7. Menu Controls.txt < prev    next >
Text File  |  1994-04-10  |  8KB  |  48 lines

  1. Menu Controls
  2.   Menu controls must be of type "List or Menu", and be linked to a MENU resource.  The MENU resource can be created and edited with ResEdit.
  3.  
  4. Setup
  5.   BaseCt uses Menu Manager routines to initialize and display menus. The MenuHandle associated with each menu control can be found in cHiData (after calling GetCtl), and used with Menu Manager toolbox calls.
  6.   Menu controls appear as static text items (with the typical frame and style options), but display pop-up menus when clicked.  The pop-up menu is aligned with the left side of the control unless the control's text is right-justified, in which case the menu is aligned with the right side of the control.  The menu can be also be popped up either above or below the control (see "Options" below).
  7.   Each menu control represents a separate instance of the associated MENU resource (unless the option to use an existing menu is set - see "Options" below).  A copy of the linked MENU is made when the control is initialized, and destroyed when the control is disposed of.  Also note that a control's menu is not inserted in the menu list until the control is clicked, thereby avoiding conflicts with other instances based on the same MENU resource.
  8.   A useful trick which you see us using at the top of this window is to place an untitled, transparent menu control above a static, non-text control.  This creates the impression that the static icon or picture itself is a menu control.  Note that it is not necessary for the icon to be the same size as the menu control, and that it is the menu control which determines the area that is hilited when pressed.
  9.  
  10. Operation
  11.   In addition to the auto-processing and data linking options discussed below, menu controls that contain program or standard menu items behave in the same way as items in the main menu bar menus (i.e., the program items generate menu events when selected, and the standard items take care of themselves).
  12.   One difference between main menus and the menus in menu controls is that the associated menu ID does not need to be equal to the MENU resource ID - 900.  On the other hand, you don't want to pick a menu ID that will conflict with existing menus, so it is still a good idea to be aware of the menu ID usage table presented in the FaceIt Guide:
  13.  101-190 - recommended for program menus
  14.  191-195 - reserved for temporary use by drivers
  15.  196-199 - reserved for ViewIt's FSSC menus
  16.  236-255 - reserved for control/DA private use
  17. and the typical values of uMenuID returned from DoLoop or MdlWnd:
  18.  ‚Ä¢ zero (for unprocessed System 7 Apple Events)
  19.  ‚Ä¢ a menu ID (101-190)
  20.  ‚Ä¢ an FWND ID (1000-1099 or > 7499)
  21.  ‚Ä¢ a module's baseID (1100-7499)
  22. Thus menu ID values > 255 can be used as menu IDs in menu controls if they do not conflict with other ID numbers that might also get returned in uMenuID.
  23.  
  24. Options
  25.   The following bit values can be added to VarCode to set various menu control options:
  26. 1 = single-selection menu.  Forces BaseCt to display the first checked menu item as the control's title, and affects "auto-processing" of menus described below.  (If no item is checked, the control title is shown.)
  27. 2 = display arrow in title.  Displays the downward pointing arrow that Apple recommends using to show presence of a pop-up menu.
  28. 4 = display menu "above" the menu control (rather than below it).  For single-selection menu controls, the menu is popped-up above the control so that the currently checked item is beneath the cursor.  For multi-selection menu controls, the entire menu is shown above the menu control.  If this bit is not set, then the menu appears as a "pull-down" menu.
  29. 8 = auto-process.  For single-selection menus, the selected item is checked and all others in the menu are unchecked.  For multi-selection menu controls, the selected item's checked state is toggled.  Note that this bit does not affect the normal menu events that get posted when program, standard, or labeled menu items are selected.
  30. 16 = use an existing, already initialized, non-main menu (rather than initializing a new instance).  This option is useful when a programmer wishes to use a menu in a menu control that has been initialized and  is being maintained by the main program.
  31. 32 = vertically center the control's title
  32. 64 = do not hilite control when hit
  33. 128 = use control's font and font size in menu (vs. the System font).  A major limitation of this option is that only System fonts contain the check mark and command key characters, so you won't be able to use this option with menus that contains such characters.  One exception:  For auto-processed menu controls (VarCode option 8), BaseCt will display the "‚Ä¢" character in place of a check mark when the font in use is not the System font.  Known Microsoft Bug:  When using a menu control in a program that is running along with MS Word under MultiFinder or System 7, then the font size used in the menu will always be 12 point.
  34. 4096 = use "dimming" instead of inversion or color switching to hilite the control.  "Hilited Appearance" under "Overview" presents a complete discussion of hilite options.
  35.  
  36. Data Linking
  37.   The data linking supported by menu controls is very similar to that described for scrollable lists.  The menu control's "value" corresponds to a long integer (32 bits) that can be linked to any program variable (see "Data Links" in the ViewIt Guide for more info on data linking).  For single-selection menus, this value is equal to the number of the currently checked menu item.  For multi-selection menus, the control's value is equal to the sum of the bit values corresponding to the checked items in the menu.  For example, if the first, third, and fifth menu items are checked in a multi-selection menu, then the menu's "value" will equal 1 + 4 + 16 = 21.  If no items are checked, then the menu's value = 0 (for both menu types).
  38.   Data linking works best when the "auto-process" option is in use since, in this case, it makes sense to think of the menu as having a single "value".  On GetVal, for example, an integer value is returned that indicates which items in the menu are checked.  On SetVal, the checked state of menu items is updated to reflect the value of the linked program variable.
  39.   When the "auto-process" option is not in use, then it makes more sense to treat menu controls as normal menus.  In this case "labeled" items are often used in such menus since ViewIt's SetItm command makes it easy to manipulate any number of instances of labeled items in any number of menu controls (see "Menu Utilities" for more info).
  40.  
  41. Limitations
  42. ‚Ä¢ Do not use menuIDs that are already in use by menus in the main menu bar (a main menu cannot also be used as a non-main menu).
  43. ‚Ä¢ Any hierarchical menus attached to items in control menus do not get initialized or inserted by BaseCt (so the main program must do this or have the menus auto-initialized by FaceIt).
  44. ‚Ä¢ Do not use FaceIt's standard "program-wide" menu items in menu controls (Quit, Delete, etc.).
  45. ‚Ä¢ Never dispose of or release the original MENU resource associated with menu controls.
  46. ‚Ä¢ When using GetVal or SetVal with multi-selection menus, the maximum number of menu items that can be affected is 32 since the menu's internal "value" is a 4-byte (32-bit) integer.  This restriction does not apply to single-selection menus.
  47. ‚Ä¢ If using SetItm to manage the state of menu items in menu controls, you will not be able to pass the res ID or menuID of the linked MENU since a new instance of the MenuHandle is created for each menu control (call GetCtl and pass MenuHandle from cHiData).
  48. ‚Ä¢ No support for hand scrolling.